home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1994 November / Cd Ware (Nro. 2) - Epimundo.iso / DOS / PG / RKEY31C.ZIP / DEMOAPPW.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-05  |  2.7 KB  |  71 lines

  1. // DemoAppD - C++ Language/Windows version of the RegKey demonstration program.
  2. //            Demonstrates the use of file-based registration key validation
  3. //            within a program using the RegKey system. Displays one of two
  4. //            simple messages based upon whether or not the user is
  5. //            registered. To test in registerd mode, use KeyGen to generate
  6. //            a *.KEY registration key file for DemoApp, and place that file
  7. //            in the current default directory. To test in unregistered mode
  8. //            remove any valid *.KEY files from the current default
  9. //            directory.
  10.  
  11.  
  12. #include "windows.h"
  13. #include <stdio.h>                                 /* Included for sprintf() */
  14.  
  15. #include "regkey.h"        // This must be included in any program using RegKey
  16.  
  17.  
  18. class CDemoApp            // Object to represent an instance of the application
  19.    {
  20. public:
  21.    void initialize(void);         // Application instance initialization method
  22.  
  23. private:
  24.    RKVALID RegisteredMode;                // Member to store mode to operate in
  25.    char RegistrationString[256];            // To store name of registered user
  26.    };
  27.  
  28.  
  29. int PASCAL WinMain(HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPCSTR lpCmdLine, int nCmdShow)
  30.    {
  31.    CDemoApp theApp;
  32.  
  33.    theApp.initialize();                   // Initalize the application instance
  34.  
  35.    return(0);
  36.    }
  37.  
  38.  
  39. void CDemoApp::initialize(void)          // Application instance initialization
  40.    {
  41.    char szMessage[200];
  42.    
  43.    // Check for a valid registration key file
  44.  
  45.    RegKeyFileValidate("*.KEY",             // Filespec of registration key file
  46.                       "0C9HMN1NDL",            // Application's validation code
  47.                       "Your Name", 0L,         // Your RegKey registration info
  48.                       RegistrationString,         // Where to place reg. string
  49.                       255,                       // Maximum size of reg. string
  50.         (RKVALID *)   &RegisteredMode);        // To store result of validation
  51.  
  52.  
  53.    if(RegisteredMode == RK_REGISTERED)
  54.       {
  55.       // If we are operating in registered mode, display registered message
  56.  
  57.       sprintf(szMessage, "DemoApp is registered to: %s\n"
  58.                          "Thanks for registering DemoApp!\n",
  59.                          RegistrationString);
  60.       MessageBox(NULL, szMessage, "DemoApp", MB_OK|MB_ICONINFORMATION);
  61.       }
  62.    else
  63.       {
  64.       // If operating in UNregistered mode, display UNregistered message
  65.  
  66.       sprintf(szMessage, "DemoApp is NOT registered\n"
  67.                          "Please remember to register DemoApp!\n");
  68.       MessageBox(NULL, szMessage, "DemoApp", MB_OK|MB_ICONSTOP);
  69.       }
  70.    }
  71.